<?php
/* SVN FILE: $Id$ */
/**
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.cake.libs.view.templates.scaffolds
 * @since         CakePHP(tm) v 0.10.0.1076
 * @version       $Revision$
 * @modifiedby    $LastChangedBy$
 * @lastmodified  $Date$
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
?>

<table width="100%">
<tr>
<td>

<div align="center">
<?php

global $wakka;

include("Wakka.class.php");
echo "<table width='70%'>";
echo "<tr>";
echo "<td>";
echo "<h2 align='left'>";
echo sprintf(__("%s", true), $singularHumanName)." ".${$singularVar}[$modelClass]["id"];
echo "</h2>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>";
echo "<table width='100%' class='data'>";
echo "<tr>";
echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("title")."</b>: ".${$singularVar}[$modelClass]["title"];
echo "</div>";
echo "</td>";
echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("type")."</b>: ";
$_field = "type_id";
foreach ($associations['belongsTo'] as $_alias => $_details)
{
	if ($_field === $_details['foreignKey']) {
	   echo ${$singularVar}[$_alias][$_details['displayField']];
	   break;
	};
};
echo "</div>";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("priority")."</b>: ";
$_field = "priority_id";
foreach ($associations['belongsTo'] as $_alias => $_details)
{
	if ($_field === $_details['foreignKey']) {
	   echo ${$singularVar}[$_alias][$_details['displayField']];
	   break;
	};
};
echo "</div>";
echo "</td>";

echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("report")."</b>: ";
$_field = "report_id";
foreach ($associations['belongsTo'] as $_alias => $_details)
{
	if ($_field === $_details['foreignKey']) {
	   echo ${$singularVar}[$_alias][$_details['displayField']];
	   break;
	};
};
echo "</div>";
echo "</td>";

echo "</tr>";

echo "<tr>";
echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("Created")."</b>: ".${$singularVar}[$modelClass]["created"];
echo "</div>";
echo "</td>";

echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("Modified")."</b>: ".${$singularVar}[$modelClass]["modified"];
echo "</div>";
echo "</td>";

echo "</tr>";

echo "<tr>";
echo "<td>";
echo "<div align='left'>";
echo "<b>".Inflector::humanize("user")."</b>: ".${$singularVar}[$modelClass]["user_id"];
echo "</div>";
echo "</td>";

echo "<td>";
echo "</td>";

echo "</tr>";

echo "</table>";

echo "</th>";
echo "</tr>";
echo "<tr>";
echo "<th  align='right'>";
echo "<table class='data'><tr><td>";
echo "\t\t".$html->link('Edit',   array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " \n";
echo "</td><td>";
echo "\t\t".$html->link('Delete', array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). "\n";
echo "</td></tr></table>";
echo "</th>";
echo "</tr>";
echo "<tr class='altrow'>";
echo "<td>";
echo "<table><tr><td>";
$wakka = new Wakka(array(),$html);
echo "<div class='wikisource' align='left'>".$wakka->Format(${$singularVar}[$modelClass]["body"],"wakka","page")."</div>";
echo "</td></tr></table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
?>
	</dl>
</div>

<?php
if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $_alias => $_details): ?>
<div class="related">
	<h3><?php echo sprintf(__("Related %s", true), Inflector::humanize($_details['controller']));?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?>
	<dl>
<?php
		$i = 0;
		$otherFields = array_keys(${$singularVar}[$_alias]);
		foreach ($otherFields as $_field) {
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
			echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n";
			echo "\t\t<dd{$class}>\n\t" . ${$singularVar}[$_alias][$_field] . "\n&nbsp;</dd>\n";
		}
?>
	</dl>
<?php endif; ?>
	<div class="actions">
		<ul>
			<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
		</ul>
	</div>
</div>
<?php
endforeach;
endif;

if (empty($associations['hasMany'])) {
	$associations['hasMany'] = array();
}
if (empty($associations['hasAndBelongsToMany'])) {
	$associations['hasAndBelongsToMany'] = array();
}
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
$i = 0;
foreach ($relations as $_alias => $_details):
$otherSingularVar = Inflector::variable($_alias);
?>
<div class="related">
<?php if (!empty(${$singularVar}[$_alias])):?>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
	<td>
	<h3 align="left"><?php echo sprintf(__("%s", true), Inflector::humanize($_details['controller']));?></h3>
	</td>
	</tr>
	<tr>
<?php
		$otherFields = array_keys(${$singularVar}[$_alias][0]);
		foreach ($otherFields as $_field) {
			echo "\t\t<th>" . Inflector::humanize($_field) . "</th>\n";
		}
?>
		<th class="actions">Actions</th>
	</tr>
<?php
		$i = 0;
		foreach (${$singularVar}[$_alias] as ${$otherSingularVar}):
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
		echo "\t\t<tr{$class}>\n";

			foreach ($otherFields as $_field) {
				echo "\t\t\t<td>" . ${$otherSingularVar}[$_field] . "</td>\n";
			}

			echo "\t\t\t<td class=\"actions\">\n";
			echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
			echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
			echo "\t\t\t</td>\n";
		echo "\t\t</tr>\n";
		endforeach;
?>
	</table>
<?php endif; ?>
	<div class="actions">
		<ul>
			<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add',${$singularVar}[$modelClass][$primaryKey]));?> </li>
		</ul>
	</div>
</div>


</td>
</tr>
</table>

</td>
</tr>
</table>

<?php endforeach;?>
